//
//  TextItem.swift
//  MySwiftPullToRefresh
//
//  Created by likai on 2017/5/4.
//  Copyright © 2017年 terry. All rights reserved.
//

import UIKit

final class TextItem{
    private let loadingText: String
    
    private let pullingText: String
    
    private let releaseText: String
    
    private let font: UIFont
    
    private let color: UIColor
    
    let label = UILabel()
    
    init(loadingText:String,pullingText:String,releaseText:String,font:UIFont,color:UIColor){
        
        self.loadingText = loadingText
        self.pullingText = pullingText
        self.releaseText = releaseText
        self.font = font
        self.color = color
        
        label.textColor = color
        label.font = font
        
    }
    
    func updateRefreshState(_ isRefreshing: Bool){
        label.text = isRefreshing ? loadingText : pullingText
        label.sizeToFit()
        
    }
    
    func updateProgress(_ progress: CGFloat){
        label.text = progress == 1 ? releaseText : pullingText
        label.sizeToFit()
        
    }
}
